﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Data.SqlClient;
using System.Data;
using System.Configuration;
using System.Text.RegularExpressions;

public partial class newnodeinfo : System.Web.UI.Page
{
    string nodeId;
    protected void Page_Load(object sender, EventArgs e)
    {
        nodeId = "n1";//Request.QueryString["nodeId"];
        SqlConnection sqlcon = null;
        SqlCommand sqlcmd = null;
        sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["testLottery"].ConnectionString);
        sqlcon.Open();
        string cmd = "select * from Node where id='" + nodeId + "';";
        sqlcmd = new SqlCommand(cmd, sqlcon);
        SqlDataAdapter da = new SqlDataAdapter(cmd, sqlcon);
        DataSet ds = new DataSet();
        da.Fill(ds, "anyway");
        DetailsView1.DataSource = ds.Tables["anyway"].DefaultView;
        DetailsView1.DataKeyNames = new string[] { "id" };
        DetailsView1.DataBind();
        sqlcon.Close();
    }
    protected void Button1_Click(object sender, EventArgs e)
    {
        SqlConnection sqlcon = null;
        SqlCommand sqlcmd = null, sqlcmd2 = null;
        string cmd = "";
        sqlcon = new SqlConnection(ConfigurationManager.ConnectionStrings["testLottery"].ConnectionString); //sqlcon = new SqlConnection(constring);
        sqlcon.Open();
        cmd = "update Node set score = " + RadioButtonList1.SelectedValue + ",stime ='" + DateTime.Today.ToShortDateString() + "'where id = '" + nodeId + "';";
        sqlcmd = new SqlCommand(cmd, sqlcon);
        sqlcmd.ExecuteNonQuery();
        string cmd2 = "select * from Node where id='" + nodeId + "';";
        sqlcmd2 = new SqlCommand(cmd2, sqlcon);
        SqlDataAdapter da = new SqlDataAdapter(cmd2, sqlcon);
        DataSet ds = new DataSet();
        da.Fill(ds, "anyway");
        DetailsView1.DataSource = ds.Tables["anyway"].DefaultView;
        DetailsView1.DataKeyNames = new string[] { "id" };
        DetailsView1.DataBind();
        sqlcon.Close();
    }
}